<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorator="layouts/pui-account-discovery-main">
<div layout:fragment="page-content">
  <h4 class="txt-c pbxxl ptxl" th:text="${T(org.springframework.util.StringUtils).hasText(clientName) ? 'Sign in to continue to ' + clientName : 'Sign in to continue'}">
    Choose an account
  </h4>

  <div th:if="${param.error}" th:unless="${error}" class="alert alert-error mbxl">
    <p th:text="#{'login.' + ${param.error[0]}}">Error Message</p>
  </div>
  <div th:if="${error}" class="alert alert-error">
    <p th:text="#{'login.' + ${error}}">Error Message</p>
  </div>
  <div th:if="${param.success}" class="alert alert-success mbxl">
    <p th:text="#{'login.' + ${param.success}}">Success Message</p>
  </div>

  <div class="choose">
    <ul class="list-group">
      <li class="list-group-item" th:each="account, iter : ${savedAccounts}" th:inline="text">
        <form th:id="${account.userId}" action="/login/idp_discovery" th:action="@{/login/idp_discovery}" method="post" role="form">
          <input type="hidden" class="form-control" name="email" th:value="${account.origin == 'uaa' || account.origin == 'ldap' ? account.username : account.email}" />
        </form>
        <a href="#" th:onclick="'javascript:document.getElementById(\'' + ${account.userId} + '\').submit();'">
          <span class="account-avatar txt-c ptl txt-m" th:style="'background-color: rgb(' + ${account.red} + ',' + ${account.green} + ',' + ${account.blue} +')'">
            <div class="h2 abbr txt-c pan man em-high">[[${account.username[0]}]]</div>
          </span>
          <span class="email-address txt-m mll pvxl">
          [[${account.username}]]
          </span>
        </a>
        <span class="remove-account">
          <a th:href="@{/delete_saved_account(userId=${account.userId})}"><div class="fa fa-icon fa-close pull-right phl txt-m type-neutral-5"></div></a>
        </span>
      </li>
    </ul>
  </div>
  <div class="addl-actions txt-c mbxl mtxxl clearfix">
    <div class="action">
      <a th:href="@{/login(otherAccountSignIn=true)}">Sign in to another account</a>
    </div>
  </div>
</div>
</html>
